import request from "@/utils/request";

enum API{
    //分页的数据
    ALLROLE_URL = "/admin/acl/role/",

    //角色新增的接口
    ADDROLE_URL = "/admin/acl/role/save",

    //角色的修改的接口
    UPDATEROLE_URL = "/admin/acl/role/update",

    //分配角色数据的接口
    ALLOTROLE_URL = "/admin/acl/permission/toAssign/",

    //给角色分配权限
    SETPERMISTION_URL = '/admin/acl/permission/doAssign/?',

    //删除角色的接口'
    DELETEROLE_URL = "/admin/acl/role/remove/",


}

//获取全部数据并渲染
export const reqAllRoles =(page:number,limit:number,jobs:string)=>request.get(API.ALLROLE_URL+`${page}/${limit}/?roleName=${jobs}`);
//新增和更新角色数据
export const reqAddOrUpdateRole =(data:any)=>{
    if (data.id) {
  return  request.put(API.UPDATEROLE_URL,data);

    }else {
 return   request.post(API.ADDROLE_URL,data);
     }

}

//角色菜单数据
export const reqAllotRole =(id:number)=>request.get(API.ALLOTROLE_URL+`${id}`);

export const reqSetPermisstion =(roleId:number,data:any)=>request.post(API.SETPERMISTION_URL+`roleId=${roleId}&permissionId=${data}`);

//删除指定id的角色数据
export const reqDeleteRoles =(id:number)=>request.delete(API.DELETEROLE_URL+`${id}`);


